<!--
OpenWPFChart library WellLogChart control default style.
Copyright Oleg V. Polikarpotchkin 2008-2009
-->
<!--revision $Id$-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:parts="clr-namespace:OpenWPFChart.Parts;assembly=OpenWPFChart.Parts"
    xmlns:local="clr-namespace:OpenWPFChart.Controls">
	
	<!-- WellLogChart Control Style -->
	<Style TargetType="{x:Type local:WellLogChart}">
		<Style.Resources>
			<!-- Item template -->
			<DataTemplate x:Key="itemTemplate">
				<parts:Item DataView="{Binding}"
					ToolTip="{Binding ItemData.ItemName}" 
					ContextMenu="{Binding Path=ContextMenu, 
						RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WellLogChart}}}"/>
			</DataTemplate>

			<!-- WellLog Header MinMaxValueConverter -->
			<local:EnumerableMinMaxValueConverter x:Key="minMaxValueConverter"/>
			
			<!-- WellLog Header Template -->
			<DataTemplate x:Key="SampledCurveHeaderTemplate">
				<Border BorderThickness="1" BorderBrush="Bisque">
					<Grid HorizontalAlignment="Stretch" ShowGridLines="False">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="Auto"/>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
							<ColumnDefinition Width="Auto" SharedSizeGroup="MinValue"/>
							<ColumnDefinition/>
							<ColumnDefinition Width="Auto" SharedSizeGroup="MaxValue"/>
						</Grid.ColumnDefinitions>

						<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
						<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="3,0,0,0"
							   Text="{Binding Path=ItemData.Points, Converter={StaticResource minMaxValueConverter}}"/>
						<Image Grid.Column="2" Stretch="None" HorizontalAlignment="Center"
						   VerticalAlignment="Center">
							<Image.Source>
								<DrawingImage>
									<DrawingImage.Drawing>
										<Binding Path="PointMarker"/>
									</DrawingImage.Drawing>
								</DrawingImage>
							</Image.Source>
						</Image>
						<TextBlock Grid.Column="3" VerticalAlignment="Center"
							Text="{Binding Path=ItemData.Points, Converter={StaticResource minMaxValueConverter}, ConverterParameter=true}"/>
						<Rectangle Grid.Row="1" Grid.ColumnSpan="4" 
							Fill="{Binding Path=Pen.Brush}" Height="2"
							VerticalAlignment="Center" HorizontalAlignment="Stretch"
							Margin="0,5,0,5"/>
					</Grid>
				</Border>
			</DataTemplate>
			
			<local:ItemCountToVisibilityConverter x:Key="itemCountToVisibility"/>
		</Style.Resources>
		
		<!-- Base ListBox ItemsPanel Template -->
		<Setter Property="ItemsPanel">
			<Setter.Value>
				<ItemsPanelTemplate>
					<Canvas />
				</ItemsPanelTemplate>
			</Setter.Value>
		</Setter>

		<!-- Base ListBox ItemContainer Style -->
		<Setter Property="ItemContainerStyle">
			<Setter.Value>
				<Style TargetType="{x:Type ListBoxItem}">
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type ListBoxItem}">
								<ContentPresenter x:Name="ContentHost"/>
								<ControlTemplate.Triggers>
									<Trigger Property="Selector.IsSelected" Value="True">
										<Setter TargetName="ContentHost" Property="BitmapEffect">
											<Setter.Value>
												<DropShadowBitmapEffect Color="Black" Direction="320" 
																		ShadowDepth="5" Softness="0.2" 
																		Opacity="0.8"/>
											</Setter.Value>
										</Setter>
									</Trigger>
								</ControlTemplate.Triggers>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
			</Setter.Value>
		</Setter>

		<!-- Base ListBox ItemTemplate -->
		<Setter Property="ItemTemplate" Value="{StaticResource itemTemplate}"/>

		<!-- WellLogChart Control Template -->
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:WellLogChart}">
					<Border Name="Bd"
							BorderThickness="{TemplateBinding Border.BorderThickness}" 
							BorderBrush="{TemplateBinding Border.BorderBrush}" 
							Background="{TemplateBinding Panel.Background}" 
							Padding="1,1,1,1" 
							SnapsToDevicePixels="True">
						<ScrollViewer
								HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
								Padding="{TemplateBinding Control.Padding}" Focusable="False">
							<Grid ShowGridLines="False"
								  Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, 
									Path=Items.Count, Converter={StaticResource itemCountToVisibility}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto"/>
									<RowDefinition Height="Auto"/>
								</Grid.RowDefinitions>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto"/>
									<ColumnDefinition Width="Auto"/>
								</Grid.ColumnDefinitions>

								<!-- WellLogHeader - Horizontal Top WellLog axes -->
								<ListBox Grid.Column="1" VerticalAlignment="Top"
									ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ItemsSource}"
									ItemTemplate="{StaticResource SampledCurveHeaderTemplate}"
									SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem}"
									HorizontalContentAlignment="Stretch"
									Background="Transparent"
									Grid.IsSharedSizeScope="True"/>

								<!-- Vertical Left Depth axis -->
								<Grid Grid.Row="1">
									<Grid.RowDefinitions>
										<RowDefinition Height="Auto"/>
										<RowDefinition/>
									</Grid.RowDefinitions>

									<parts:LinearAxis x:Name="depthAxis" 
										AxisScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.HorizontalScale}"/>
									<TextBlock Grid.Row="1" HorizontalAlignment="Center" 
										Text="{TemplateBinding DepthAxisTitle}"
										Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=(parts:Axis.Pen).Brush}"/>

									<Grid.LayoutTransform>
										<RotateTransform Angle="90"/>
									</Grid.LayoutTransform>
								</Grid>

								<!-- Chart area -->
								<Grid Grid.Row="1" Grid.Column="1">
									<!--Coordinate grids-->
									<parts:Grid
										HorizontalScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.VerticalScale}"
										VerticalScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.HorizontalScale}"
										GridVisibility="{TemplateBinding VerticalGridVisibility}"
										Fill="{TemplateBinding VerticalGridFill}"
										AlternateFill="{TemplateBinding VerticalGridAlternateFill}"
									/>
									<parts:Grid Orientation="Horizontal"
										HorizontalScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.VerticalScale}"
										VerticalScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.HorizontalScale}"
										GridVisibility="{TemplateBinding HorizontalGridVisibility}"
										Fill="{TemplateBinding HorizontalGridFill}"
										AlternateFill="{TemplateBinding HorizontalGridAlternateFill}"
									/>
									<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
								</Grid>
							</Grid>
						</ScrollViewer>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
